/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.minetsh.imaging.view;

import ohos.app.Context;
import ohos.media.image.PixelMap;

/**
 * GlobalData
 *
 * @since 2021-07-27
 */
public class GlobalData {
    private static volatile GlobalData sInstance;
    private Context context;

    private PixelMap resultPixelMap;

    private PixelMap cropperPixelMap;

    private GlobalData() {
    }

    /**
     * getInstance
     *
     * @return GlobalData
     */
    public static GlobalData getInstance() {
        if (sInstance == null) {
            synchronized (GlobalData.class) {
                if (sInstance == null) {
                    sInstance = new GlobalData();
                }
            }
        }
        return sInstance;
    }

    /**
     * init
     *
     * @param initContext initContext
     */
    public void init(Context initContext) {
        this.context = initContext;
    }

    /**
     * 获取上下文
     *
     * @return 上下文
     */
    public Context getContext() {
        return context;
    }

    /**
     * 获取PixelMap
     *
     * @return PixelMap
     */
    public PixelMap getResultPixelMap() {
        return resultPixelMap;
    }

    /**
     * 设置PixelMap
     *
     * @param resultPixelMap PixelMap
     */
    public void setResultPixelMap(PixelMap resultPixelMap) {
        this.resultPixelMap = resultPixelMap;
    }

    /**
     * 获取处理后的PixelMap
     *
     * @return PixelMap
     */
    public PixelMap getCropperPixelMap() {
        return cropperPixelMap;
    }

    /**
     * setCropperPixelMap
     *
     * @param cropperPixelMap PixelMap
     */
    public void setCropperPixelMap(PixelMap cropperPixelMap) {
        this.cropperPixelMap = cropperPixelMap;
    }
}
